package cn.edu.usst.cs.nxy;

public class Main {
    public static void main(String[] args) {
        int[][] magicSquare = {
                { 47, 58, 69, 80, 1, 12, 23, 34, 45 },
                { 57, 68, 79, 9, 11, 22, 33, 44, 46 },
                { 67, 78, 8, 10, 21, 32, 43, 54, 56 },
                { 77, 7, 18, 20, 31, 42, 53, 55, 66 },
                { 6, 17, 19, 30, 41, 52, 63, 65, 76 },
                { 16, 27, 29, 40, 51, 62, 64, 75, 5 },
                { 26, 28, 39, 50, 61, 72, 74, 4, 15 },
                { 36, 38, 49, 60, 71, 73, 3, 14, 25 },
                { 37, 48, 59, 70, 81, 2, 13, 24, 35 }
        };

        int centerRow = magicSquare.length / 2;
        int centerCol = magicSquare[0].length / 2;

        int sum = 0;
        int count = 0;

        System.out.print("找到被7整除的数字: ");
        // 按照提示的规则查找并处理数字
        for (int i = 0; i < magicSquare.length; i++) {
            int numToCheck = Math.min(i + 1, magicSquare.length - i);
            for (int j = magicSquare[0].length - numToCheck; j < magicSquare[0].length; j++) {
                int num = magicSquare[i][j];
                if (num % 7 == 0) {
                    sum += num;
                    count++;
                    System.out.print(num + " ");
                }
            }
        }

        System.out.print("\n");
        System.out.println("被7整除的数字的个数: " + count);
        System.out.println("这些数字的和: " + sum);
    }
}